<?php
		require_once('../inc/Checkout.php');
		/*$totalamount1 = 0.00;
		foreach($_REQUEST as $row){
		   $totalamount1 += ($row['ammount']);
		}
		echo $totalamount1;*/
		$finalamount = TotalAmount();
		echo $finalamount;
        if(isset($_POST['buy']))
        {
        require_once '../inc/anet_php_sdk/AuthorizeNet.php'; // Make sure this path is correct.
        $transaction = new AuthorizeNetAIM('2Mhn9V2Wb2', '6773qxN2M2YdP5xj');
        
        $transaction->amount = $_POST['price'];
        $transaction->card_num = $_POST['card_num'];
        $transaction->exp_date = $_POST['exp_date'];
        
        $response = $transaction->authorizeAndCapture();
        }
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Home Page</title>
    <link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
    <link rel="stylesheet" type="text/css" href="../inc/bootstrap.css">
</head>

<body>
        <? include('../inc/header.php'); ?>
        <div class="container">
                        
            <pre>
                        <?
                                if (isset($response)) {
                                        print_r($response);
                                }
                        ?>
            </pre>
				<div id="sitenav" style="width: 200px; float: left">
            		<? include('../inc/nav.php'); ?> 
                    </div>    
                <div id="contents" style="width: 650px; float: right;">                        
                         
                <form class="form-horizontal" action="?" method="post">
                <div class="control-group">
                <label class="control-label" for="inputAmount">Total Amount:</label>
                <div class="controls">
                <input class="input-large uneditable-input" type="number" name="price" for="inputAmount" value=<?= $finalamount ?> >
              
                </div>
                </div>
                <div class="control-group">
                <label class="control-label" for="inputCard" >Credit Card Number:</label>
                <div class="controls">
                <input type="text" id="inputCard"  name="card_num" class="input-large">
                </div>
                </div>
                <div class="control-group">
                <label class="control-label" for="inputExp"> Experation Date:</label>
                <div class="controls">
                <input id="inputExp" type="text" name="exp_date" class="input-large">
                </div>
                </div>
                <div class="control-group">
                <div class="controls">
                <button type="submit" class="btn" name="buy">Buy Now</button>
                </div>
                </div>
                </div>
                </div>
        <div id="fb-root"></div>
                <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) return;
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>
        
        <script>
        //$(function(){
        //$(".btn").live('click',function(){
         //                       $.post(this.href, {_method: 'DELETE'}, function(data){
         //                       },'json');	
		//								
          //                      return false;
         ///               });
        // });
		 </script>
</body>
</html>
